package com.dongdong.service.impl;

import com.alibaba.dubbo.config.annotation.Service;
import com.dongdong.mapper.TbUserMapper;
import com.dongdong.pojo.TbUser;
import com.dongdong.pojo.TbUserExample;
import com.dongdong.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

@Service
@org.springframework.stereotype.Service
public class UserServiceImpl implements UserService {
    @Autowired
    private TbUserMapper tbUserMapper;

    @Override
    public int inserterInfo(TbUser user) {
        return tbUserMapper.insert(user);
    }

    @Override
    public boolean selectByUnsername(String username) {
       TbUser tbUser =  tbUserMapper.selectByUserName(username);
        return tbUser == null?true:false;
    }

    @Override
    public TbUser selectByNname(String username) {
        TbUserExample te = new TbUserExample();
        TbUserExample.Criteria criteria = te.createCriteria();
        criteria.andUsernameEqualTo(username);
        List<TbUser> tbUsers = tbUserMapper.selectByExample(te);
        return tbUsers.size() > 0? tbUsers.get(0):null;

    }
    @Override
    public void sendPhoneMessage(String phone) {
    }
}
